package com.pro.springbootshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pro.springbootshop.entity.Wares;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface WaresMapper extends BaseMapper<Wares> {
    @Select("select * from wares " +
            "where (main_class_id=#{mainClassId} or #{mainClassId}=0 ) " +
            "and (other_class_id=#{otherClassId} or #{otherClassId}=0 ) " +
            "and (seller_id=#{sellerId} or #{sellerId}=#{admin} ) " +
            "and (wares_name like #{value}) " +
            "and (wares_state <> #{waresState}) " +
            "limit #{current},#{size}")
    List<Wares> findWares(@Param("current") int current,@Param("size") int size,@Param("mainClassId") int mainClassId,@Param("otherClassId") int otherClassId,@Param("value") String value,@Param("waresState") int waresState,@Param("sellerId") String sellerId,@Param("admin") String admin);
    @Select("select * from wares " +
            "where (main_class_id=#{mainClassId} or #{mainClassId}=0 ) " +
            "and (other_class_id=#{otherClassId} or #{otherClassId}=0 ) " +
            "and (seller_id=#{sellerId} or #{sellerId}=#{admin} ) " +
            "and (wares_state <> #{waresState}) " +
            "and (wares_name like #{value}) ")
    List<Wares> findWaresTotals(@Param("mainClassId") int mainClassId,@Param("otherClassId") int otherClassId,@Param("value") String value,@Param("waresState") int waresState,@Param("sellerId") String sellerId,@Param("admin") String admin);
    @Select("select seller_id from wares where wares_id=#{waresId}")
    String getSellerIdByWares(@Param("waresId") int waresId);
}
